package cn.topevery.garden.dal.logic;

import cn.topevery.garden.dal.dao.CarDao;
import cn.topevery.garden.entity.po.Car;
import cn.topevery.garden.entity.query.CarQuery;
import cn.topevery.garden.entity.vo.CarVO;
import cn.topevery.garden.entity.vo.oneMap.CountVO;
import cn.topevery.garden.framework.base.BaseLogic;
import hw.topevery.framework.db.base.BaseEntityDao;
import hw.topevery.framework.db.entity.DataPager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 
 *
 * @author code-generate
 * @date 2021-08-06
 */
@Service
public class CarLogic extends BaseLogic<Car> {
    @Autowired
    CarDao carDao;

    @Override
    public BaseEntityDao<Car, Integer> getDao() {
        return carDao;
    }

    

    /**
     * 获取列表
     *
     * @param query
     */
    public DataPager<Car> listPage(CarQuery query) {
        return carDao.listPage(query);
    }

    /**
     * 根据自增id批量删除
     *
     * @param ids
     */
    public void deleteBatchById(String userId,Integer[] ids) {
        carDao.delete(userId, ids);
    }


    public void saveOrUpdate(String userId, Car car){
        carDao.saveOrUpdate(userId,car);
    }

    /**
     * 描述 获取统计数量.
     *
     * @param name     the name
     * @param extentId the extent id
     * @return the list
     * @author wenzhao.lin
     * @created 2021 -08-25 09:26:38 Get count list.
     */
    public Map getCount(String name, Integer extentId, Integer typeId){
        return carDao.getCount(name, extentId, typeId);
    }

    /**
     * 描述 通过类型获取列表
     *
     * @param name       the name
     * @param extentId   the extent id
     * @param type the type
     * @return the person list by type
     * @author wenzhao.lin
     * @created 2021 -08-25 09:26:38
     */
    public List<Car> getCarListByType(String name, Integer extentId, Integer type){
        return carDao.getCarListByType(name, extentId, type);
    }

    /**
     * 描述 获取类型列表
     *
     * @param name     the name
     * @param extentId the extent id
     * @return the car type list
     * @author wenzhao.lin
     * @created 2021 -08-27 09:19:48
     */
    public List<Car> getCarTypeList(String name, Integer extentId){
        return carDao.getCarTypeList(name, extentId);
    }

    /**
     * 描述 一张图管理-人车概况- 获取车辆统计
     *
     * @return the person count
     * @author wenzhao.lin
     * @created 2021 -09-09 13:58:05
     */
    public List<CountVO> getCarCount(){
        return carDao.getCarCount();
    }

    /**
     * 描述 一张图管理-人车概况- 获取所有车辆类型统计
     *
     * @return the person type count
     * @author wenzhao.lin
     * @created 2021 -09-09 13:58:05
     */
    public List<CountVO> getCarTypeCount(){
        return carDao.getCarTypeCount();
    }

    /**
     * 描述 一张图管理-人车概况- 获取在岗车辆类型统计
     *
     * @return the person online count
     * @author wenzhao.lin
     * @created 2021 -09-09 13:58:05
     */
    public List<CountVO> getCarOnlineCount(){
        return carDao.getCarOnlineCount();
    }

    /**
     * 描述 一张图管理-人车概况- 获取车辆 在线/离线 统计
     *
     * @return the car online count
     * @author wenzhao.lin
     * @created 2021 -09-13 09:19:32
     */
    public List<CountVO> getCarOnlineAndOutCount(){
        return carDao.getCarOnlineAndOutCount();
    }

    /**
     * 描述 一张图管理-人车概况- 获取车辆列表
     *
     * @param query the query
     * @return the car list data
     * @author wenzhao.lin
     * @created 2021 -09-10 18:03:08
     */
    public DataPager<CarVO> getCarListData(CarQuery query){
        return carDao.getCarListData(query);
    }

    public CarVO getByCarId(String carId) { return carDao.getByCarId(carId);}
}
